package br.trainee.web.vo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="email_clinica")
@NamedQueries(value={
		
		@NamedQuery(name="queryBuscarEmailPorIdClinica", query="select e from EmailClinicaVO e where e.clinica.idPessoa= :idClinica and e.status.tipoStatus =:tipoStatus"),
		@NamedQuery(name="queryBuscarEmailPorId", query="select e from EmailClinicaVO e where e.idEmailClinica = :idEmail")
})
public class EmailClinicaVO{
	
	@Id
	@SequenceGenerator(name="sqEmailClinica", sequenceName="sq_email_clinica", allocationSize=1)
	@GeneratedValue(strategy= GenerationType.SEQUENCE, generator="sqEmailClinica")
	@Column(name="id_email_clinica")
	private Long idEmailClinica;
	
	@Column(name="email_clinica")
	private String emailClinica;
	
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="id_clinica",referencedColumnName="id_clinica")
	private ClinicaVO clinica;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_status",referencedColumnName="id_status")
	private StatusVO status;
	
	
	public EmailClinicaVO() {
		
	}
	
	public Long getIdEmailClinica() {
		return idEmailClinica;
	}
	public void setIdEmailClinica(Long idEmailClinica) {
		this.idEmailClinica = idEmailClinica;
	}
	
	
	public String getEmailClinica() {
		return emailClinica;
	}
	public void setEmailClinica(String emailClinica) {
		this.emailClinica = emailClinica;
	}
	
	
	public ClinicaVO getClinica() {
		return clinica;
	}
	public void setClinica(ClinicaVO clinica) {
		this.clinica = clinica;
	}

	
	public StatusVO getStatus() {
		return status;
	}
	public void setStatus(StatusVO status) {
		this.status = status;
	}
	
	@Override
	public boolean equals(Object objeto) {
		if(objeto == null || !(objeto instanceof EmailClinicaVO)){
			
			return false;
		}
			
			EmailClinicaVO email = (EmailClinicaVO) objeto;
			return email.emailClinica.equals(this.emailClinica);
	}
	
	@Override
	public int hashCode() {
		
		return this.emailClinica.hashCode();
	}

}
